package com.jiaai.cloud.wx.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author 佳爱网络科技
 * @since 2017-08-22
 */
@TableName("t_wxgoods")
public class TWxgoods extends Model<TWxgoods> {

    private static final long serialVersionUID = 1L;

    /**
     * 商品id
     */
	@TableId(value="goodsid", type= IdType.AUTO)
	private Integer goodsid;
    /**
     * 商品名称
     */
	private String goodsname;
    /**
     * 商品图片
     */
    @JSONField(serialize = false)
	private String goodspic;
    /**
     * 商品价格
     */
	private Double goodsprice;


	public Integer getGoodsid() {
		return goodsid;
	}

	public void setGoodsid(Integer goodsid) {
		this.goodsid = goodsid;
	}

	public String getGoodsname() {
		return goodsname;
	}

	public void setGoodsname(String goodsname) {
		this.goodsname = goodsname;
	}

	public String getGoodspic() {
		return goodspic;
	}

	public void setGoodspic(String goodspic) {
		this.goodspic = goodspic;
	}

	public Double getGoodsprice() {
		return goodsprice;
	}

	public void setGoodsprice(Double goodsprice) {
		this.goodsprice = goodsprice;
	}

	@Override
	protected Serializable pkVal() {
		return this.goodsid;
	}

	public String getGoodsintroduce() {
		return goodsintroduce;
	}

	public void setGoodsintroduce(String goodsintroduce) {
		this.goodsintroduce = goodsintroduce;
	}

	/**
	 * 商品的介绍
	 */
	private String goodsintroduce;

	public List<String> getPiclist() {
		if(StringUtils.isEmpty(goodspic)){
			return this.piclist;
		}
		if( goodspic.indexOf(",") <= 0 ){
			this.piclist.add(this.goodspic);
			return this.piclist;
		}
		return Arrays.asList(this.goodspic.split(","));

	}

	public void setPiclist(List<String> piclist) {
		this.piclist = piclist;
	}

	/**
	 * 商品图片url数组
	 */
	@TableField(exist = false)
	private List<String> piclist = new ArrayList<>();

	/**
	 * 商品分类id
	 */
	private Integer goodsclassid;

	public Integer getGoodsclassid() {
		return goodsclassid;
	}

	public void setGoodsclassid(Integer goodsclassid) {
		this.goodsclassid = goodsclassid;
	}

	/**
	 * 超级发布, 多个地址
	 */
	private String goodsaddress;

	public String getGoodsaddress() {
		return goodsaddress;
	}

	public void setGoodsaddress(String goodsaddress) {
		this.goodsaddress = goodsaddress;
	}

}
